<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var a=100
        var obj={
            a:200,
            fn:function(){
            console.log(this.a)
        }
        }
        function fn(){
            console.log(this.a)
        }
        fn.call(obj)//200怎么实现

        fn.call(null)
        fn.call(undefined)
        fn.call(window)//借给的对象是null或者underfined相当于借给了window


        Function.prototype.call1=function (object){
            var context=object||window
            //context.fn=this
            context.唯一的值=this
            // return context.fn()
            const res=context.fn()
            delete context.fn()
            return res
        }
        Function.prototype.call1=function (object,...arg){
            var context=object||window
            context.fnName=Symbol()
            context[fnName]=this
            const res=context[fnName](...arg)
            delete context[fnName]
            return res
        }
        fn.call1(obj)
    </script>
</body>
</html>
